package com.ScoresSystem.service.Impl;

import com.ScoresSystem.mapper.ScoreMapper;
import com.ScoresSystem.pojo.Score;
import com.ScoresSystem.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ScoreServiceImpl implements ScoreService {

    @Autowired
    ScoreMapper scoreMapper;

    @Override
    public List<Score> getAllScore(String name, int pageIndex, Integer pageSize) {
        return scoreMapper.getAllScore(name, pageIndex, pageSize);
    }

    @Override
    public int getCount(String name) {
        return scoreMapper.getCount(name);
    }

    @Override
    public Score findScoreByStudentNoAndSubjectId(Integer studentNo, Integer subjectId) {
        return scoreMapper.findScoreByStudentNoAndSubjectId(studentNo, subjectId);
    }

    @Override
    public int addScore(Score score) {
        return scoreMapper.addScore(score);
    }

    @Override
    public int updateScore(Score score) {
        return scoreMapper.updateScore(score);
    }

    @Override
    public int deleteScore(Integer id) {
        return scoreMapper.deleteScore(id);
    }

    // 获取所有学生成绩统计数据
    @Override
    public List<Score> getScoreAccount() {
        return scoreMapper.getScoreAccount();
    }

    // 获取当前学生的成绩
    @Override
    public List<Score> getMyScore(String studentNo, int pageIndex, Integer pageSize) {
        return scoreMapper.getMyScore(studentNo, pageIndex, pageSize);
    }

    // 获取当前学生的成绩数量
    @Override
    public int getMyScoreCount(String studentNo) {
        return scoreMapper.getMyScoreCount(studentNo);
    }

    @Override
    public List<Score> getMyScoreAccount(String studentNo) {
        return scoreMapper.getMyScoreAccount(studentNo);
    }

}
